home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / telecomm / bbs / movietech.lha / mdb.rexx next >
Encoding:
OS/2 REXX Batch file  |  1994-11-27  |  7.8 KB  |  271 lines

  1. /* mdb.trans (c) '94 by Georg 'Gio' Magschok                                 */
  2. /*                                                                           */
  3. /* $VER: mdb.trans 1.0a (29.11.94)                                           */
  4. /* an ARexx-script for TechnoBBS to access                                   */
  5. /* MovieMUI V3.0 and later written by Andre 'ABernie' Bernhardt              */
  6. /* Adapted to TBBS by Kenneth Fribert                                        */
  7.  
  8. options results
  9. ln=arg(1)
  10. LineName=Con_LineActive(ln)
  11. If LineName = "" Then Exit 10
  12. Address value linename
  13. LogEntry "MovieMui started"
  14.  
  15. CR = D2C(13)
  16. LF = D2C(10)
  17. CRLF = CR||LF
  18. ESC = D2C(27)
  19. WHITE = ESC||"[0m"
  20. RED = ESC||"[31m"
  21. GREEN = ESC||"[32m"
  22. YELLOW = ESC||"[33m"
  23. BLUE = ESC||"[34m"
  24. PURPLE = ESC||"[35m"
  25. CYAN = ESC||"[36m"
  26. CLEAR = D2C(12)
  27.  
  28. menuname ='bbs:text/mdbmenu'
  29. selmenu  ='bbs:text/mdbselmenu'
  30. mmui     ='run >nil: work:moviedatabase/MovieMUI errorfile errorlevel=0 debuglevel=0 quiet'
  31. autoquit = 1            /* specify 1 to QUIT MovieMUI after use,0 to */
  32. tempfile ='t:mdbtemp'||ln
  33.  
  34.  
  35. if (~show('p','MOVIEMUI')) then do
  36.     SendModem 'MovieMUI is being launched...'
  37.     address command mmui
  38.     address command 'waitforport MOVIEMUI'
  39. end
  40. SendModem CRLF
  41.  
  42. if autoquit=1 then do
  43.     if Open('mdbuse','env:mdbusers',R) then do
  44.         num=Readln('mdbuse')
  45.             Close('mdbuse')
  46.     end
  47.     else
  48.         num=0
  49.     Open('mdbuse','env:mdbusers',W)
  50.     WriteLn('mdbuse',num+1)
  51.     Close('mdbuse')
  52. end
  53.  
  54. do until cmd='Q'
  55.     if Upper(GetUserExtension(ln))='.TXT' then sendascii menuname
  56.     cmd=Upper(AskInput(ln, "("||GetTimeLeft(ln)||") "||CYAN||"[MDB - Commands: M A S I Q ]"||WHITE, "", 255))
  57.     select
  58.         when cmd='Q' then SendModem CRLF
  59.         when cmd='M' then call moviesearch
  60.         when cmd='A' then call personsearch
  61.         when cmd='S' then call selectivesearch
  62.         when cmd='I' then call info
  63.         otherwise do
  64.             GetHotKey(ln,CRLF||RED||'Unknown command'||WHITE||CRLF||CYAN||"Press Any key to continue..."||WHITE)
  65.         end
  66.     end
  67. end
  68.  
  69. stopit:
  70. if autoquit=1 then do
  71.     Open('mdbuse','env:mdbusers',R)
  72.     num=Readln('mdbuse')
  73.            Close('mdbuse')
  74.     Open('mdbuse','env:mdbusers',W)
  75.     WriteLn('mdbuse',num-1)
  76.     Close('mdbuse')
  77.     if num=1 then do
  78.         SendModem YELLOW||"Shutting down Movie Data Base"||WHITE||CRLF
  79.         address 'MOVIEMUI' 'QUIT'
  80.     end
  81. end
  82. LogEntry "MovieMUI ended"
  83. exit
  84.  
  85.  
  86. moviesearch:
  87. Movie=AskInput(ln,CRLF||"("||GetTimeLeft(ln)||") "||CYAN||"What film to search for?"||WHITE, "", 255)
  88. LogEntry "MovieMUI searching for movie="||Movie
  89. if movie~='' then do
  90.     SendModem CRLF||CYAN||"MovieDataBase is being searched for '"||YELLOW||movie||CYAN||"'"||WHITE||CRLF
  91.     address 'MOVIEMUI' 'GET "'||movie||'" FROM MOVIE'
  92.     mdbtext=result
  93.     if mdbtext='RESULT' | RC~=0 then
  94.         GetHotKey(ln, CRLF||RED||"The movie was not found! Try with selective search!"||CRLF||CYAN||"Press any key to continue..."||WHITE)
  95.     else
  96.         call showresult
  97.     end
  98. return
  99.  
  100. personsearch:
  101. person=AskInput(ln,CRLF||"("||GetTimeLeft(ln)||") "||CYAN||"Person to search for (Lastname, Firstname)?"||WHITE, "", 255)
  102. LogEntry "MovieMUI searching for person="||person
  103. if person~='' then do
  104.     SendModem CRLF||CYAN||"MovieDataBase is being searched for '"||YELLOW||person||CYAN||"'"||WHITE||CRLF
  105.     address 'MOVIEMUI' 'GET "'||person||'" FROM ANY'
  106.     mdbtext=result
  107.     if mdbtext='RESULT' | RC~=0 then
  108.         GetHotKey(ln, CRLF||RED||"The person was not found! Try with selective search!"||CRLF||CYAN||"Press any key to continue..."||WHITE)
  109.     else
  110.         call showresult
  111.     end
  112. return
  113.  
  114. selectivesearch:
  115. address 'MOVIEMUI' 'UNSELECT KEY=0' ; skey=result
  116. numentries='all'
  117. stl=''
  118. do until cmd='Q'
  119.     if Upper(GetUserExtension(ln))='.TXT' then sendascii selmenu
  120.     SendModem CRLF||YELLOW||numentries||WHITE||' Datasets are selected!'||CRLF
  121.     cmd=Upper(AskInput(ln, "("||GetTimeLeft(ln)||") "||CYAN||" [Select - Commands: 0-9 U N G F Q ] "||WHITE, "", 255))
  122.     einschr=0
  123.     select
  124.         when cmd='Q' then SendModem CRLF
  125.         when cmd=''  then SendModem CRLF
  126.         when cmd='0' then do
  127.             sts='MOVIE'
  128.             stl='MovieTitel'
  129.             einschr=1
  130.         end
  131.         when cmd='1' then do
  132.             sts='ACR'
  133.             stl='Actor'
  134.             einschr=1
  135.         end
  136.         when cmd='2' then do
  137.             sts='ACS'
  138.             stl='Actress'
  139.             einschr=1
  140.         end
  141.         when cmd='3' then do
  142.             sts='COMP'
  143.             stl='Composer'
  144.             einschr=1
  145.         end
  146.         when cmd='4' then do
  147.             sts='COST'
  148.             stl='Costume Designer'
  149.             einschr=1
  150.         end
  151.         when cmd='5' then do
  152.             sts='DIR'
  153.             stl='Regisseur'
  154.             einschr=1
  155.         end
  156.         when cmd='6' then do
  157.             sts='ED'
  158.             stl='Editor'
  159.             einschr=1
  160.         end
  161.         when cmd='7' then do
  162.             sts='PRDE'
  163.             stl='Production Designer'
  164.             einschr=1
  165.         end
  166.         when cmd='8' then do
  167.             sts='PROD'
  168.             stl='Producer'
  169.             einschr=1
  170.         end
  171.         when cmd='9' then do
  172.             sts='WRITE'
  173.             stl='Author'
  174.             einschr=1
  175.         end
  176.         when cmd='U' then do
  177.             address 'MOVIEMUI' 'UNDOSELECT KEY='||skey
  178.             numentries=result
  179.         end
  180.         when cmd='N' then do
  181.             numentries='all'
  182.             address 'MOVIEMUI' 'ENDSELECTION KEY='||skey
  183.             address 'MOVIEMUI' 'UNSELECT KEY=0'
  184.             skey=result
  185.         end
  186.         when cmd='G' then call getsel
  187.         when cmd='F' then call getfromsel
  188.     otherwise
  189.         GetHotKey(ln,CRLF||RED||"Unknown command"||CRLF||CRLF||CYAN||"Press any key to continue..."||WHITE||CRLF)
  190.     end
  191.     if einschr=1 then do
  192.         pattern=AskInput(ln,'Limiting pattern (in AmigaOS-conventions, ?, #? and *)'||CRLF||"for "||stl||":","",255)
  193.         if pattern~='' then do
  194.             do while pos('*',pattern)>0
  195.                 sternpos=pos('*',pattern)
  196.                 pattern=left(pattern,sternpos-1)||'#?'||right(pattern,length(pattern)-sternpos)
  197.             end
  198.             SendModem "MovieDataBase is searched with "||CYAN||stl||WHITE||"='"||YELLOW||pattern||WHITE||"'..."
  199.             address 'MOVIEMUI' 'SELECT KEY='||skey||' "'||pattern||'" FROM '||sts ; numentries=result
  200.             if RC~=0 then do
  201.                 GetHotKey(ln,CRLF||RED||'Error with last pattern, removing last selection...'||CRLF||CRLF||CYAN||"Press any key to continue..."||WHITE||CRLF)
  202.                 address 'MOVIEMUI' 'UNDOSELECT KEY='||skey
  203.                 numentries=result
  204.             end
  205.         end
  206.     end
  207. end
  208. address 'MOVIEMUI' 'ENDSELECTION KEY='||skey
  209. cmd=''
  210. return
  211.  
  212. getsel:
  213. if numentries=0 | numentries='all' | stl='' then
  214.     GetHotKey(ln,CRLF||RED||"No Data is selected!"||CRLF||CYAN||"Press any key to continue..."||WHITE||CRLF)
  215. else
  216.     if ((numentries > 100) | (numentries='all')) then do
  217.         GetHotKey(1,RED||"There's more than 100 datasets selected!"||CRLF||"Please limit the search further!"||CRLF||CYAN||"Press any key to continue..."||WHITE)
  218.     end
  219.     else do
  220.         address 'MOVIEMUI' 'GETSELECTION KEY='||skey
  221.         mdbtext=result
  222.         if mdbtext='RESULT' | RC~=0 then
  223.             GetHotKey(ln,CRLF||RED||"Well, nothing found, sorry!"||CRLF||CYAN||"Press any key to continue..."||WHITE||CRLF)
  224.         else
  225.             call showresult
  226.     end
  227. return
  228.  
  229. getfromsel:
  230. if numentries=0 | numentries='all' | stl='' then
  231.     GetHotKey(ln,CRLF||RED||"No Data is selected!"||CRLF||CYAN||"Press any key to continue..."||WHITE||CRLF)
  232. else do
  233.     frose=AskInput(ln,"("||GetTimeLeft(ln)||") "||CYAN||"Which "||stl||" (Number 1.."||numentries||") do you wish to view? "||WHITE, "", 255)
  234.     if frose~='' & datatype(frose)='NUM' then do
  235.         if frose>0 & frose<numentries+1 then do
  236.             address 'MOVIEMUI' 'GETFROMSELECTION KEY='||skey||' NUMBER='||frose
  237.             mdbtext=result
  238.             if mdbtext='RESULT' | RC~=0 then
  239.                 GetHotKey(ln,CRLF||RED||"Well, nothing found, sorry!"||CRLF||CYAN||"Press any key to continue..."||WHITE||CRLF)
  240.             else
  241.                 call showresult
  242.         end
  243.     end
  244. end
  245. return
  246.  
  247. info:
  248.     SendModem YELLOW||"mdb.rexx V1.0a (C)'94 by Georg 'Gio' Magschok"||CRLF||"Adapted to english, cleaned up and done for TechnoBBS by Kenneth Fribert"||CRLF
  249.     address 'MOVIEMUI' 'INFO "title"'
  250.     mdbtext=CYAN||result
  251.     address 'MOVIEMUI' 'INFO "author"'
  252.     mdbtext=mdbtext||", by "||result||CRLF
  253.     address 'MOVIEMUI' 'INFO "copyright"'
  254.     mdbtext=mdbtext||"© "||result||CRLF
  255.     address 'MOVIEMUI' 'INFO "description"'
  256.     mdbtext=mdbtext||result||CRLF
  257.     address 'MOVIEMUI' 'INFO "version"'
  258.     mdbtext=mdbtext||result||CRLF
  259.     address 'MOVIEMUI' 'GETSTATISTIC'
  260.     mdbtext=mdbtext||result||CRLF
  261.     call showresult
  262. return
  263.  
  264. showresult:
  265.     Open('mdbfile',tempfile,W)
  266.     Writeln('mdbfile',mdbtext)
  267.     Close('mdbfile')
  268.     SendAscii tempfile
  269.     GetHotKey(ln,CRLF||CYAN||"Press any key to continue..."||WHITE)
  270. return
  271.